<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>返回第n个父元素节点</title>
</head>
<body>
    <div>
        <p><strong><i></i></strong></p>
    </div>
</body>
<script>
    function retParent(elem, n = 0) {
        while(elem && n) {
            elem = elem.parentElement;
            n--;
        }
        return elem;
    }
    var i = document.getElementsByTagName('i')[0];
</script>
</html>
